package com.dzzw.Servlet.EmployeeServlet;

import com.dzzw.Dao.EmployeeDao;
import com.dzzw.Model.Employee;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/View/EmployeeLoginServlet")
public class EmployeeLoginServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private final EmployeeDao employeeDao = new EmployeeDao();
    public EmployeeLoginServlet(){
        super();
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String employee_actnumber = request.getParameter("employee_actnumber");
        String employee_password = request.getParameter("employee_password");
        List<Employee> list = employeeDao.EmployeeLogin(employee_actnumber,employee_password);
        HttpSession session = request.getSession();
        session.setAttribute("EmployeeLogin", list);//传值
        response.sendRedirect("/View/Employee.jsp");
        System.out.println("公务员登录成功");
    }
}
